n,a,b=map(int,input().split())

v1=dict()

result=0

for i in range(0,a):
    index,value=map(int,input().split())
    v1[index]=value

for i in range(0,b):
    index,value=map(int,input().split())
    if index in v1.keys():
        result+=v1[index]*value

print(result)